/**
 * create by young (young2f@outlook.com) on 2020/12/4
 * 考勤
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    treeId: { type: String, _type: 'code', title: '编码', required: true },
    recordId: { type: String, _type: 'code', title: '编码', required: true },
    code: { type: String, _type: 'code', title: '员工编码', required: true },
    personnel: { type: String, _type: 'code', title: '员工', required: true },

    date: { type: Date, _type: 'date', title: '日期', required: true, enableArea: [ 'table', 'detail', 'search' ] },
    name: { type: String, _type: 'string', title: '姓名', required: true,disabled:true, enableArea: [ 'table', 'detail', 'search' ] },
    inDate: { type: Date, _type: 'date', title: '入职时间', required: true,disabled:true, enableArea: [ 'table', 'detail', 'search' ] },
    department: { type: String, _type: 'string', title: '部门', required: true,disabled:true, enableArea: [ 'table', 'detail', 'search' ] },
    level: { type: String, _type: 'string', title: '职级', required: true,disabled:true, enableArea: [ 'table', 'detail', 'search' ] },

    workDay: { type: Number, _type: 'number', title: '出勤天数',  enableArea: [ 'table', 'detail' ] },
    SJDay: { type: Number, _type: 'number', title: '事假天数',  enableArea: [ 'table', 'detail',] },
    BJDay: { type: Number, _type: 'number', title: '病假天数',  enableArea: [ 'table', 'detail',  ] },
    breakDay: { type: Number, _type: 'number', title: '工休天数',  enableArea: [ 'table', 'detail', ] },
    publicHolidayAay: { type: Number, _type: 'number', title: '公休天数',  enableArea: [ 'table', 'detail',  ] },
    JBGZ: { type: Number, _type: 'number', title: '基本工资',  enableArea: [ 'table', 'detail',  ] },
    QQJ: { type: Number, _type: 'number', title: '全勤奖',  enableArea: [ 'table', 'detail',  ] },
    BXGXJ: { type: Number, _type: 'number', title: '表现贡献奖',  enableArea: [ 'table', 'detail',  ] },
    JBF: { type: Number, _type: 'number', title: '加班费',  enableArea: [ 'table', 'detail',  ] },
    QQKK: { type: Number, _type: 'number', title: '缺勤扣款',  enableArea: [ 'table', 'detail',  ] },
    CB: { type: Number, _type: 'number', title: '餐补',  enableArea: [ 'table', 'detail',  ] },
    HFBT: { type: Number, _type: 'number', title: '话费补贴',  enableArea: [ 'table', 'detail',  ] },
    JTBT: { type: Number, _type: 'number', title: '交通补贴',  enableArea: [ 'table', 'detail',] },
    GWBT: { type: Number, _type: 'number', title: '高温补贴',  enableArea: [ 'table', 'detail',  ] },
    FK: { type: Number, _type: 'number', title: '罚款',  enableArea: [ 'table', 'detail',  ] },
    GZJX: { type: Number, _type: 'number', title: '工作绩效',  enableArea: [ 'table', 'detail',  ] },
    RWJX: { type: Number, _type: 'number', title: '任务绩效',  enableArea: [ 'table', 'detail',  ] },
    YJTC: { type: Number, _type: 'number', title: '业绩提成',  enableArea: [ 'table', 'detail',  ] },
    SB: { type: Number, _type: 'number', title: '社保',  enableArea: [ 'table', 'detail',  ] },
    GJJ: { type: Number, _type: 'number', title: '公积金',  enableArea: [ 'table', 'detail',  ] },
    GS: { type: Number, _type: 'number', title: '个税',  enableArea: [ 'table', 'detail', ] },
    YFGZ: { type: Number, _type: 'number', title: '应发工资',  enableArea: [ 'table', 'detail', ] },
    QK: { type: Number, _type: 'number', title: '欠款',  enableArea: [ 'table', 'detail', ] },
    SFGZ: { type: Number, _type: 'number', title: '实发工资',  enableArea: [ 'table', 'detail',  ] },
    memo: { type: String, _type: 'string', title: '备注',  enableArea: [ 'table', 'detail', ] },
    fileList: { type: Array, _type: 'fileList', title: '图片列表' },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('DicPerPayroll', _schema);
};
